#include <stdlib.h>
#include <string.h>
#include "gamelogi.h"
#include "config.h"
#include "queue.h"
#include "GQueue.h"
#include "structs.h"
#include "sprite.h"

ConfigInfo conf;
int last_sc;
char *double_buffer;
Queue keys_queue;
GQueue* mouse_queue;
Game game;


/**
 * Esta função é responsável por carregar todas as sprites do jogo.
 */
void loadSprites(){
	game.loading = create_sprite(level1Introbg_xpm);
	game.gameover= create_sprite(level1Introbg_xpm);
	game.win = 		 create_sprite(level1Introbg_xpm);
	game.hero.stone.sprite = create_sprite(rock_xpm);
	game.hero.sight = create_sprite(cross);
	game.liveSprite = create_sprite(mustachelives_xpm);
	game.loadingText = create_sprite(loading_xpm);
	game.hero.sprite = create_sprite(mm_xpm);
	
	game.level1.bgCollision  = create_sprite(level1bgCollision_xpm);
	game.level1.background   = create_sprite(level1bg_xpm);	
	game.level1.enemy.sprite = create_sprite(mouseSmallToLeft_xpm);
	
	game.level1.intro.bg = create_sprite(level1Introbg_xpm);
	game.level1.intro.logo = create_sprite(logo_xpm);
	game.level1.intro.sequel = create_sprite(Sequel_xpm);
	game.level1.intro.title = create_sprite(L1Intro_title_xpm);
	game.level1.intro.text = create_sprite(L1Intro_Text_xpm);
	game.level1.intro.mouse1 = create_sprite(mouse1_xpm);
	game.level1.intro.mouse2 = create_sprite(mouse2_xpm);
	
	game.level2.bgCollision  = create_sprite(level2bgCollision_xpm);
	game.level2.background   = create_sprite(level2bg_xpm);	
	game.level2.enemy.sprite = create_sprite(mouseSmallToLeft_xpm);
	
	game.level2.intro.bg = create_sprite(level1Introbg_xpm);
	game.level2.intro.logo = create_sprite(logo_xpm);
	game.level2.intro.sequel = create_sprite(Sequel_xpm);
	game.level2.intro.title = create_sprite(Level2Intro_Title_xpm);
	game.level2.intro.text = create_sprite(Level2Intro_Text_xpm);
	game.level2.intro.mouse1 = create_sprite(mouse1_xpm);
	game.level2.intro.mouse2 = create_sprite(mouse2_xpm);
	
	game.level3.bgCollision  = create_sprite(level3bgCollision_xpm);
	game.level3.background   = create_sprite(level3bg_xpm);	
	game.level3.enemy.sprite = create_sprite(monster_xpm);

	game.level3.intro.bg = create_sprite(level1Introbg_xpm);
	game.level3.intro.logo = create_sprite(logo_xpm);
	game.level3.intro.sequel = create_sprite(Sequel_xpm);
	game.level3.intro.title = create_sprite(Level3Intro_Title_xpm);
	game.level3.intro.text = create_sprite(Level3Intro_Text_xpm);
	game.level3.intro.mouse1 = create_sprite(mouse1_xpm);
	game.level3.intro.mouse2 = create_sprite(mouse2_xpm);
	
}


/**
 * Esta função inicia e termina o jogo.
 */
int main(int argc, char* argv[]){
	initialize(&conf);
	loadSprites();
	main_loop();
	finalize(&conf);
	return 0;
}
